<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('绑定用户')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-user-add" class="form-horizontal">
        <input name="userId" th:value="${userId}" id="sysUserId" hidden/>
        <input name="wxUserId" id="wxUserId" hidden/>
        <h4 class="form-header h4">会员信息</h4>
        <div class="row">
            <div class="col-sm-9">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">手机号码：</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <input id="phoneNum" placeholder="请输入手机号码进行查询" class="form-control"
                                   type="text" maxlength="11" required>
                            <span class="input-group-addon"><i class="fa fa-search" onclick="searchVip()"></i></span>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-9">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">微信昵称：</label>
                    <div class="col-sm-8">
                        <input name="nickName" id="nickName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30"
                               required readonly>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<!--<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>-->
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script>
    function searchVip() {
      var phoneNum=  $('#phoneNum').val()
       $.post(ctx+"/emp/emp/searchUser",{phoneNum:phoneNum},function (res) {
           if (res.code==0){
               $("#nickName").val(res.data.nickName)
               $("#wxUserId").val(res.data.id)
           } else {
               $.modal.alertWarning(res.msg)
           }
       })
    }
    function submitHandler(index, layero){
        var sysUserId = $("#sysUserId").val()
        var wxUserId = $("#wxUserId").val()
        if (!wxUserId) {
            $.modal.alertWarning("请选择绑定的微信用户")
        }
        $.post(ctx+"/emp/emp/toAdd",{sysUserId:sysUserId,wxUserId:wxUserId},function (res) {
            if (res.code==0){
                $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
            } else {
                $.modal.alertWarning(res.msg)
            }
        })

    }

</script>
</body>
</html>